import request from '@/utils/request'

export default {
  getModelSensorList(searchModel) {
    return request({
      url: '/modelSensor/list',
      method: 'get',
      params: {
        deviceName: searchModel.deviceName,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  addModelSensor(modelSensor) {
    return request({
      url: '/modelSensor/add',
      method: 'post',
      data: modelSensor
    })
  },
  saveModelSensor(modelSensor) {
    if (modelSensor.id == null || modelSensor.id === undefined) {
      return this.addModelSensor(modelSensor)
    }
    return this.updateModelSensor(modelSensor)
  },
  updateModelSensor(modelSensor) {
    return request({
      url: '/modelSensor/update',
      method: 'put',
      data: modelSensor
    })
  },
  getModelSensorById(id) {
    return request({
      // url: '/modelSensor/' + id,
      url: `/modelSensor/${id}`,
      method: 'get'
    })
  },
  deleteModelSensorById(id) {
    return request({
      url: `/modelSensor/delete/${id}`,
      method: 'delete'
    })
  },
  getAllModelSensorList() {
    return request({
      url: '/modelSensor/all',
      method: 'get'
    })
  },
}
